/*! ******************************************************************************
 *
 * Created on 2022-06-16 11:18
 *
 * Copyright(c) YuZhou Big Data Laboratory CO.,Ltd, 2022.  All rights reserved.
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/
package org.yzbdl.lanius.ui.action;

import org.yzbdl.lanius.core.net.HttpUtil;

import cn.hutool.http.server.HttpServerRequest;
import cn.hutool.http.server.HttpServerResponse;

/**
 * 基础Action类，HttpUtil.sacnActionPackage方法会扫描并注册
 *
 * @author yzbdl@yzbdl.ac.cn
 * @version 1.0
 * @date 2020-06-16 11:19
 */
public abstract class BaseServerAction {

    /**
     * 注册服务器请求
     */
    public void registerAct() {
        HttpUtil.server.addAction(getUrl(), (req, res) -> doAction(req, res));
    }

    /**
     * 获取RequestMapping
     */
    public abstract String getUrl();

    /**
     * 处理请求和返回内容
     */
    public abstract void doAction(HttpServerRequest req, HttpServerResponse res);
}
